class StandardsController < ApplicationController
  layout "land"
  before_filter :authorize, :grade
  def subject_word_type_list
    @subject_word_types = SubjectWordType.find(:all)
  end
  
  def create_subject_word_type
    @subject_word_type = SubjectWordType.new(params[:subject_word_type])
    if @subject_word_type.save
    flash[:notice] = "新词表类型添加成功！"
    redirect_to :action => 'subject_word_type_list'
    end
  end
  
  def edit_subject_word_type
    @subject_word_type = SubjectWordType.find(params[:id])
  end
  
  def update_subject_word_type
    @subject_word_type = SubjectWordType.find(params[:id])
    if @subject_word_type.update_attributes(params[:subject_word_type])
    flash[:notice] = "词表被成功更新！"
    redirect_to :action => 'subject_word_type_list'
    else
     render :action => 'edit_subject_word_type'
    end
  end
  def destroy_subject_word_type
    SubjectWordType.find(params[:id]).destroy
    flash[:notice] = "该词表已被删除！"
    redirect_to :action => 'subject_word_type_list'
  end
  
  def classification
    @classification_types = ClassificationType.find(:all)
  end
  
  def create_classification_type
    @classification_type = ClassificationType.new(params[:classification_type])
    if@classification_type.save
    flash[:notice] = "新分类标准添加成功！"
    redirect_to :action => 'classification'
    end
  end
  
  def edit_classification_type
    @classification_type = ClassificationType.find(params[:id])
  end
  
  def update_classification_type
    @classification_type = ClassificationType.find(params[:id])
    if@classification_type.update_attributes(params[:classification_type])
    flash[:notice] = "分类标准信息更新完毕！"
    redirect_to :action => 'classification'
    else
    render :action => "edit_classification_type"
    end
  end
    
  def destroy_classification_type
    ClassificationType.find(params[:id]).destroy
    flash[:notice] = "该分类法已被删除！"
    redirect_to :action => 'classification'
  end
  
  def language
    @language_encodings = LanguageEncoding.find_all
  end
  
  def add_language_encoding
    @language_encoding = LanguageEncoding.new(params[:language_encoding])
    if @language_encoding.save
      flash[:notice] = "语种代码信息添加成功！"
      redirect_to :action => "language"
    end
  end
  
  def edit_language_encoding
    @language_encoding = LanguageEncoding.find(params[:id])
  end
  
  def update_language_encoding
    @language_encoding = LanguageEncoding.find(params[:id])
    if @language_encoding.update_attributes(params[:language_encoding])
    flash[:notice] = "该语种代码信息更新成功！"
    redirect_to :action => "language"
    end
  end
  
  def destroy_language_encoding
    LanguageEncoding.find(params[:id]).destroy
    flash[:notice] = "该语种代码已被删除！"
    redirect_to :action => "language"
  end
  
  def create_type
    @create_types = CreateType.find_all
  end
  
  def add_create_type
    @create_type = CreateType.new(params[:create_type])
    if @create_type.save
    flash[:notice] = "添加著作方式成功！"
    redirect_to :action => "create_type" 
    end
  end
  
  def edit_create_type
    @create_type = CreateType.find(params[:id])
  end
  
  def update_create_type
    @create_type = CreateType.find(params[:id])
    if @create_type.update_attributes(params[:create_type])
    flash[:notice] = "著作方式更新成功！"
    redirect_to :action => "create_type"
    end
  end
  
  def destroy_create_type
    CreateType.find(params[:id]).destroy
    flash[:notice] = "该著作方式已被删除！"
    redirect_to :action => "create_type"
  end
  
  def contribute_type
    @contribute_types = ContributeType.find_all
  end
  
  def add_contribute_type
    @contribute_type = ContributeType.new(params[:contribute_type])
    if @contribute_type.save
    flash[:notice] = "添加著作方式成功！"
    redirect_to :action => "contribute_type" 
    end
  end
  
  def edit_contribute_type
    @contribute_type = ContributeType.find(params[:id])
  end
  
  def update_contribute_type
    @contribute_type = ContributeType.find(params[:id])
    if @contribute_type.update_attributes(params[:contribute_type])
    flash[:notice] = "著作方式更新成功！"
    redirect_to :action => "contribute_type"
    end
  end
  
  def destroy_contribute_type
    ContributeType.find(params[:id]).destroy
    flash[:notice] = "该著作方式已被删除！"
    redirect_to :action => "contribute_type"
  end
  
  def audience_type
    @audience_types = AudienceType.find_all
  end
  
  def add_audience_type
    if AudienceType.create(params[:audience_type])
      flash[:notice] = "读者对象代码添加成功！"
      redirect_to :action => "audience_type"
    end
  end
  
  def edit_audience_type
    @audience_type = AudienceType.find(params[:id])
  end
  
  def update_audience_type
    if AudienceType.find(params[:id]).update_attributes(params[:audience_type])
    flash[:notice] = "读者对象代码信息更新成功！"
    redirect_to :action => "audience_type"
    end
  end
  
  def destroy_audience_type
    AudienceType.find(params[:id]).destroy
    flash[:notice] = "该读者对象代码删除成功！"
    redirect_to :action => "audience_type"
  end
  
  def types
    @types = Type.find_all
  end
  
  def edit_type
    @typeo = Type.find(params[:id])
  end
  
  def update_type
    if Type.find(params[:id]).update_attributes(params[:typeo])
      flash[:notice] = "载体类型本地化信息更新成功！"
      redirect_to :action => "types"
    end
  end
  
  def identifier_type
    @identifier_types = IdentifierType.find_all
  end
  
  def add_identifier_type
    if IdentifierType.create(params[:identifier_type])
      flash[:notice] = "唯一标识类型添加成功！"
      redirect_to :action => "identifier_type"
    end
  end
  
  def edit_identifier_type
    @identifier_type = IdentifierType.find(params[:id])
  end
  
  def update_identifier_type
    if IdentifierType.find(params[:id]).update_attributes(params[:identifier_type])
      flash[:notice] = "唯一标识类型更新成功！"
      redirect_to :action => "identifier_type"
    end
  end
  
  def destroy_identifier_type
    if IdentifierType.find(params[:id]).destroy
      flash[:notice] = "该唯一标识类型已被删除！"
      redirect_to :action => "identifier_type"
    end
  end
  
  def citation_type
    @citation_types = CitationType.find_all
  end
  
  def add_citation_type
    if CitationType.create(params[:citation_type])
      flash[:notice] = "文献引用类型添加成功！"
      redirect_to :action => "citation_type"
    end
  end
  
  def edit_citation_type
    @citation_type = CitationType.find(params[:id])
  end
  
  def update_citation_type
    if CitationType.find(params[:id]).update_attributes(params[:citation_type])
      flash[:notice] = "文献引用类型更新成功！"
      redirect_to :action => "citation_type"
    end
  end
  
  def destroy_citation_type
    if CitationType.find(params[:id]).destroy
      flash[:notice] = "该文献引用类型删除成功！"
      redirect_to :action => "citation_type"
    end
  end
  
  def version_doc
    @version_doc_pages, @version_docs = paginate :version_docs, :per_page => 10
  end
  
  def show_version_doc
    @version_doc = VersionDoc.find(params[:id])
  end
  
  def edit_version_doc
    @version_doc = VersionDoc.find(params[:id])
  end
  
  def add_version_doc
    @version_doc = VersionDoc.new(params[:version_doc])
    if @version_doc.save
      flash[:notice] = "多版本文献添加成功！"
      redirect_to :action => "show_version_doc", :id => @version_doc
    end
  end
  
  def update_version_doc
    if VersionDoc.find(params[:id]).update_attributes(params[:version_doc])
      flash[:notice] = "多版本文献信息更新成功！"
      redirect_to :action => "show_version_doc", :id => params[:id]
    end
  end
  
  def destroy_version_doc
    if VersionDoc.find(params[:id]).destroy
      flash[:notice] = "该多版本文献已被删除！"
      redirect_to :action => "version_doc"
    end
  end
end
